import { Injectable } from '@angular/core';
import {HttpClient, HttpHeaders} from "@angular/common/http";
import {PageInfo, Student} from "./student";
import {Observable} from "rxjs";
const httpOptions = {
  headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
@Injectable({
  providedIn: 'root'
})
export class StudentService {
  private url="api/student/"

  constructor(private http:HttpClient) { }
  save(student:Student){
    this.http.post<Student>(`${this.url}save`,student,httpOptions).pipe().subscribe(s=>student.id=s.id)
  }
  list(pageNum:number,pageSize:number):Observable<PageInfo>{
    var pageation={
      pageNum:pageNum,
      pageSize:pageSize
    }
    return this.http.post<PageInfo>(`${this.url}list`,pageation,httpOptions).pipe()

  }
}
